//package Filter;
//
//import javax.servlet.*;
//import javax.servlet.annotation.WebFilter;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//
//@WebFilter("/*")
//public class LoginFilter implements Filter {
//    @Override
//    public void init(FilterConfig filterConfig) throws ServletException {
//        System.out.println("过滤器来了，用来前置处理拦截操作");
//    }
//
//    @Override
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        System.out.println("触发");
//        servletRequest.setCharacterEncoding("utf-8");
//        servletResponse.setContentType("text/html;charset=utf-8");
//        HttpServletRequest servletRequest1 = (HttpServletRequest) servletRequest;
//        String requestURI = servletRequest1.getRequestURI();
//        HttpSession session = servletRequest1.getSession();
//        System.out.println("requestURI = " + requestURI);
//        System.out.println("requestURI.endsWith(\"/index.jsp\") = " + requestURI.endsWith("/index.jsp"));
//        if (requestURI.endsWith("/index.jsp")&&(requestURI.endsWith("/code"))){
//            System.out.println("放行登陆界面");
//            filterChain.doFilter(servletRequest,servletResponse);
//        } else if (session !=null && session.getAttribute("yz")!=null) {
//            System.out.println("是否正常登录");
//            filterChain.doFilter(servletRequest,servletResponse);
//        } else if (session==null && session.getAttribute("yz")==null) {
//            System.out.println("拦截非法登录");
//            HttpServletResponse servletResponse1 = (HttpServletResponse) servletResponse;
//            servletResponse1.sendRedirect("/lodinweb1_0_war_exploded/index.jsp");
//
//        }
////        放行
//        filterChain.doFilter(servletRequest, servletResponse);
//    }
//
//    @Override
//    public void destroy() {
//        System.out.println("销毁");
//    }
//}
